package leetcode;

/**
 * @Project : AlgorithmLearning
 * @Package : Leetcode
 * @File : Q0238.java
 * @Author : WangRuoyu
 * @Date 2023/11/17 22:23
 */


public class Q0238 {
    public int[] productExceptSelf(int[] nums) {
        int[] f = new int[nums.length];
        f[0] = 1;
        for (int i = 1; i < nums.length; i++) {
            f[i] = f[i - 1] * nums[i - 1];
        }
        for (int i = nums.length - 2; i >= 0; i--) {
            f[i] = f[i] * nums[i + 1];
            nums[i] *= nums[i + 1];
        }
        return f;
    }

    public static void main(String[] args) {
        Q0238 sl = new Q0238();
    }
}
